package com.woniu.job.controller;

import com.woniu.job.entity.Company;
import com.woniu.job.entity.PageBean;
import com.woniu.job.entity.Resumework;
import com.woniu.job.service.IResumeworkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttribute;


/**
 * @author 俞泽
 */
@Controller
@RequestMapping("/resumework")
public class ResumeWorkController {
    @Autowired
    private IResumeworkService resumeworkService;

    /**
     * 分页查看本企业收到的简历
     * @param model
     * @param page
     * @return resume_received
     */
    @GetMapping("/getresumework/{page}")
    public String getResume(Model model, @SessionAttribute(required = false) Company company, @PathVariable("page") Integer page){
        if (page==null || page==0){
            page=1;
        }
        if (company!=null){
            PageBean<Resumework> resumeworkPageBean =  resumeworkService.getResumeByCompany(company.getId(),page);
            model.addAttribute("myresume",resumeworkPageBean);
        }
        return "company/resume_received";
    }

    /**
     * 测试方法
     * @param model
     * @param companyId
     * @param page
     * @return
     */
//    @GetMapping("/getresumework/{page}/{companyId}")
//    public String getResume(Model model,@PathVariable("companyId")String companyId, @PathVariable("page") Integer page){
//        if (page==null || page==0){
//            page=1;
//        }
//        PageBean<Resumework> resumeworkPageBean =  resumeworkService.getResumeByCompany(companyId,page);
//        model.addAttribute("myresume",resumeworkPageBean);
//        return "company/resume_received";
//    }
}
